# -*- coding: utf-8 -*-
# @Time    : 2024/10/9 19:48
# @Author  : 荒
# @FileName: dashboard.py
# @Software: PyCharm

from django.template import Library
from web import models
from django.urls import reverse

register = Library()

@register.simple_tag
def user_space(size):
    if size >= 1024 * 1024 * 1024:
        return "%.2f GB" % (size / (1024 * 1024 * 1024),)
    elif size >= 1024 * 1024:
        return "%.2f MB" % (size / (1024 * 1024),)
    elif size >= 1024:
        return "%.2f KB" % (size / 1024,)
    else:
        return "%d B" % size